/////////////////////////////////////////////////////////////////////////////
/*/	
 *	Creator:		Joshua C. Rouzer and
					Alexander Kahl
 *	Title:			Base cpp
 *	Last Edited:	07/13/2013
 *	Summary:		
/*/
/////////////////////////////////////////////////////////////////////////////
#include "Base.h"
#include "ParticleManager.h"
#include "CSGD_TextureManager.h"
#include "CSGD_XAudio2.h"
/////////////////////////////////////////////////////////////////////////////
// Function : Constructor
// Notes	: 
/////////////////////////////////////////////////////////////////////////////
CBase::CBase(bool bTeamOne) : CDefenseStruct(bTeamOne){
	m_eType = BASE;
	m_Shield = new CShield( bTeamOne );

	CParticleManager *pMan = CParticleManager::GetInstance();
	CEmitter *StarEmitter = new CEmitter();
	StarEmitter->LoadXML("StarBackground.xml");
	StarEmitter->SetPos(0.0f, 0.0f);
	pMan->AddEmitter(StarEmitter);

	m_nBaseDeath = CSGD_XAudio2::GetInstance()->SFXLoadSound(_T("resource/Sounds/BaseExplode.wav"));
	m_nBaseHit = CSGD_XAudio2::GetInstance()->SFXLoadSound(_T("resource/Sounds/BaseHit.wav"));
	m_nWin = CSGD_XAudio2::GetInstance()->MusicLoadSong(_T("resource/Sounds/WinScreen.xwm"));
	m_nLose = CSGD_XAudio2::GetInstance()->MusicLoadSong(_T("resource/Sounds/LoseScreen.xwm"));

	// CHANGE - hardcoded positions
	if(bTeamOne){
		SetImage( CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/Images/BlueBaseArt.png")) );
		SetPosX(0);
	}
	else{
		SetImage( CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/Images/RedBaseArt.png")) );
		SetPosX(760);
	}

	SetPosY( 260 );
	SetWidth( 40 );
	SetHeight( 280 );
	SetRotation( 0 );

}
/////////////////////////////////////////////////////////////////////////////
// Function		: Destructor
// Notes		: 
/////////////////////////////////////////////////////////////////////////////
CBase::~CBase(){
	delete m_Shield;
}
/////////////////////////////////////////////////////////////////////////////
// Function		: Update
// Parameters	: dT - Time elapsed since last update
// Notes		: 
/////////////////////////////////////////////////////////////////////////////
void CBase::Update(float dT){

	m_Shield->Update(dT);
}
/////////////////////////////////////////////////////////////////////////////
// Function		: Render
// Notes		: 
/////////////////////////////////////////////////////////////////////////////
void CBase::Render(){
	CDefenseStruct::Render();

	m_Shield->Render();
}
/////////////////////////////////////////////////////////////////////////////
// Function		: Upgrade
// Notes		: Increases stats based on level
/////////////////////////////////////////////////////////////////////////////
void CBase::Upgrade(){
	m_nLevel++;
	/*	Overall Upgrades Notes
	Level 1:
		Activate the attacking generator defenses
	Level 2:
		Increase Base's health
		Increase generators' health
		Decrease Shooting through shield chance
	Level 3:
		Increase Base's health
		Increase generators' health
		Decrease Shooting through shield chance
	Level 4:
		Increase Base's health
		Increase generators' health
		Increase generators' attack
		Decrease Shooting through shield chance
	Level 5:
		Increase Base's health
		Increase generators' health
		Decrease Shooting through shield chance
	*/
	//Call everything's Upgrade
	m_Shield->Upgrade();
	if(m_nLevel != 1){
		SetMaxHealth(GetMaxHealth() + 25);
		SetHealth(GetHealth() + 25);
	}
}
/////////////////////////////////////////////////////////////////////////////
// Function		: Remove Shield
// Notes		: 
/////////////////////////////////////////////////////////////////////////////
void CBase::RemoveShield( void ){
	m_Shield->Deactivate();
}